package com.demo;

import org.quartz.*;

import java.util.Date;

/**
 * @author sourire
 * @version 1.0
 * @date 2021/7/16 22:43
 */
//工作类的具体实现
@DisallowConcurrentExecution //不允许并发执行
public class HelloJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //创建工作详情
        JobDetail jobDetail = jobExecutionContext.getJobDetail();
        String name = jobDetail.getKey().getName();
        String group = jobDetail.getKey().getGroup();
        String data = jobDetail.getJobDataMap().getString("data");
        System.out.println("job执行，job名为：" + name + ",group名为：" + group + "，数据为：" + data + new Date());
    }
}
